/*
 * Created on 2005-7-11
 *
 */
package com.et114.components.ldap4oj.support;

import javax.naming.NamingException;
import javax.naming.directory.DirContext;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class LdapUtils {
    private static final Log logger = LogFactory.getLog(LdapUtils.class);

    /**
     * Close the given context and ignore any thrown exception. This is useful
     * for typical finally blocks in manual Ldap statements.
     * 
     * @param context
     *            the Ldap context to close
     */
    public static void closeContext(DirContext context) {
        if (context != null) {
            try {
                context.close();
            } catch (NamingException ex) {
                logger.warn("Could not close context", ex);
            }
        }
    }


}
